package com.example.demo;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

public class MineActivity extends AppCompatActivity {

    TextView mTextView;
    EditText mEditTextTalk;
    EditText EditTextcity;
    TextView mtxthome;
    TextView mtxtpio;
    TextView mtxtuser;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mine);
        //隐藏标题栏
        ActionBar action = getSupportActionBar();
        if(action != null){
            action.hide();
        }

        bindView();
        Onclicklistener();
        intent();
    }


    //UI组件初始化
    private void bindView() {
        mTextView = findViewById(R.id.nickname);
        mEditTextTalk = findViewById(R.id.talk);
        EditTextcity = findViewById(R.id.city);

        mtxthome = findViewById(R.id.txt_home);
        mtxtpio = findViewById(R.id.txt_poi);
        mtxtuser = findViewById(R.id.txt_user);
    }

    //组件的点击事件
    private void Onclicklistener() {
        //主页点击事件
        mtxthome.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MineActivity.this,MainActivity.class);
                startActivity(intent);
            }
        });
        //动态的点击事件
        mtxtpio.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MineActivity.this,TalkActivity.class);
                startActivity(intent);
            }
        });
        //用户的点击事件
        mtxtuser.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

    }

    private  void intent(){
        Intent intent = getIntent();
        //从Intent当中根据key取得value
        String value = intent.getStringExtra("username");
        String talk = intent.getStringExtra("talk");
        String city = intent.getStringExtra("address");

        mTextView.setText(value);
        mEditTextTalk.setText(talk);
        EditTextcity.setText(city);

    }
}